﻿/*
 * Copyright © 2010 Project Mercury Team Members (http://mpe.codeplex.com/People/ProjectPeople.aspx)
 * 
 * This program is licensed under the Microsoft Permissive License (Ms-PL). You should
 * have received a copy of the license along with the source code. If not, an online copy
 * of the license can be found at http://mpe.codeplex.com/license.
 */

namespace ProjectMercury.Controllers
{
    using System;
    using System.Collections.Generic;
    using System.Diagnostics.CodeAnalysis;

    /// <summary>
    /// Defines a controller pipeline.
    /// </summary>
    [SuppressMessage("Microsoft.Usage", "CA2229:ImplementSerializationConstructors")]
    [Serializable]
    public class ControllerPipeline : LinkedList<AbstractController>
    {
        /// <summary>
        /// Adds additional logic to an emitter trigger event.
        /// </summary>
        /// <param name="deltaSeconds">Elapsed time in whole and fractional seconds.</param>
        /// <param name="context">The trigger context.</param>
        public void Process(Single deltaSeconds, ref TriggerContext context)
        {
            LinkedListNode<AbstractController> node = base.First;

            while (node != null)
            {
                node.Value.Process(deltaSeconds, ref context);

                // Break if the trigger has been cancelled...
                if (context.Cancelled)
                    break;

                node = node.Next;
            }
        }
    }
}